/**
 * ****************************************************************************
 * Project: RoboBridge
 * ----------------------------------------------------------------------------
 * -------------------------- [c]2012 - KrawallMann ---------------------------
 * ---------------------- http://www.krawallmann.de.tc/ -----------------------
 * ****************************************************************************
 * File: CMPS03Frame.java Package: tc.de.krawallmann.robobridge.visualization
 * Version: 1.0 Author(s): KrawallMann
 * ****************************************************************************
 * Description:
 * ****************************************************************************
 */
package tc.de.krawallmann.robobridge.visualization;

import java.awt.GridLayout;

import tc.de.krawallmann.robobridge.devices.AbstractDevice;
import tc.de.krawallmann.robobridge.devices.implementation.CMPS03;
import eu.hansolo.steelseries.extras.Compass;
import eu.hansolo.steelseries.tools.BackgroundColor;
import eu.hansolo.steelseries.tools.FrameDesign;
import eu.hansolo.steelseries.tools.FrameEffect;

/**
 * The Class CMPS03Frame.<br/>
 * Partially auto-generated Javadoc!
 */
public class CMPS03Frame extends AbstractRoboViewDisplay {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8978248671802705854L;
	/** The cmps. */
	private final Compass cmps;

	/**
	 * Instantiates a new cMP s03 frame.
	 */
	public CMPS03Frame() {
		super("DEVICE_ID_CMPS03");
		setLayout(new GridLayout(1, 1));
		cmps = new Compass();
		cmps.setBackgroundColor(BackgroundColor.DARK_GRAY);
		cmps.setFrameDesign(FrameDesign.CHROME);
		cmps.setFrameEffect(FrameEffect.EFFECT_INNER_FRAME);
		add(cmps);
		setSize(300, 300);
		setVisible(true);
	}

	/*
	 * (non-Javadoc)
	 * @see
	 * tc.de.krawallmann.robobridge.devices.SensorListener#onSensorValueChanged
	 * (tc.de.krawallmann.robobridge.devices.AbstractDevice, java.lang.String,
	 * java.lang.Object, java.lang.Object)
	 */
	@Override
	public void onSensorValueChanged(final AbstractDevice sensor, final String propertyName,
			final Object oldValue, final Object newValue) {
		if (propertyName.equals(CMPS03.CMPS03_ANGLE)) {
			cmps.setValue((Integer) newValue / 10);
		}
	}

}
